<html>
<head><meta charset="utf-8"><title>lazy-normalization and const generics · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html">lazy-normalization and const generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="174403808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174403808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174403808">(Aug 28 2019 at 21:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>: I'm interested in working on lazy normalization. Is that currently blocked on further chalk integration, or are things at the point where it would be reasonable to start working on it?</p>



<a name="174496794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174496794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174496794">(Aug 29 2019 at 22:07)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> a good question. I've been thinking that it would make sense to try and push it forward pre-Chalk. That was something I had planned to investigate tomorrow.</p>



<a name="174496807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174496807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174496807">(Aug 29 2019 at 22:07)</a>:</h4>
<p>I was going to try and look for a "coding partner" to work on PRs; maybe that could be you? :)</p>



<a name="174504897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174504897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174504897">(Aug 30 2019 at 00:28)</a>:</h4>
<p>Sounds good to me :)</p>



<a name="174682752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174682752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ranweiler <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174682752">(Sep 02 2019 at 00:19)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125294">@Aaron Hill</span>  and <span class="user-mention" data-user-id="116009">@nikomatsakis</span>. I'm trying to jump in on const generics generally.</p>
<p>I'm just getting up to speed with, well, everything, but it sounds like lazy normalization is part of the real near-term solution for some const generics bugs. I want to keep on top of work around lazy normalization, but don't want to step on anyone's toes.</p>
<p>If there's a way I can at least follow along with the lazy normalization development (and help out if desired), it would really help me contribute time effectively!</p>



<a name="174824800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174824800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174824800">(Sep 03 2019 at 20:11)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="132179">@ranweiler</span> and <span class="user-mention" data-user-id="125294">@Aaron Hill</span> -- so I spent some time investigating "lazy norm" but also const generics recently. I'll try to leave some notes here.</p>



<a name="174833266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833266">(Sep 03 2019 at 21:57)</a>:</h4>
<p>OK, so, I've done some digging, though I also got distracted by some other things.</p>



<a name="174833397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833397">(Sep 03 2019 at 21:59)</a>:</h4>
<p>One thing I've been doing is that I <a href="https://github.com/nikomatsakis/rust/tree/lazy-norm-anon-const" target="_blank" title="https://github.com/nikomatsakis/rust/tree/lazy-norm-anon-const">created a branch</a> that "fixes" the generics of constants so that they properly inherit generics from their parents. This is currently ICEing with an assertion failure, and I'm trying to figure out why -- I have been doing some edits to dump more info because the current debug rules don't give enough.</p>



<a name="174833464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833464">(Sep 03 2019 at 22:00)</a>:</h4>
<p>The idea here is that this change is the one that is theoretically blocked by lazy norm, and I'd like to udnerstand why.  I suspect we can use the existing "eager norm" strategy here as well and it should work "at least as well" as it does for associated types today, but I'm not entirely sure.</p>



<a name="174833483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833483">(Sep 03 2019 at 22:00)</a>:</h4>
<p>(That's why I'd like to reproduce the problem)</p>



<a name="174833639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833639">(Sep 03 2019 at 22:02)</a>:</h4>
<p>Separately, I think what I'd like to do is to try integrating lazy norm into the compilation in a branch and just see what problems we hit. I spent a bit of time thinking about what that would mean -- but didn't get too far. I'm debating about how to get started, basically. One problem is that the existing code manually invokes normalization in all kinds of places ('eager norm'). I suppose it would suffice to insert some logic into unification to normalize-if-needed and then to remove some of those eager normalization locations -- we don't necessarily have to remove <em>all</em> of them.</p>



<a name="174833704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174833704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174833704">(Sep 03 2019 at 22:03)</a>:</h4>
<p>Still, there are also some questions about the strategy that chalk is using right now -- so I spent some time thinking over alternatives there. I should leave some notes in <a href="https://github.com/rust-lang-nursery/chalk/issues/234" target="_blank" title="https://github.com/rust-lang-nursery/chalk/issues/234">chalk#234</a>, but I have to run at the moment.</p>



<a name="174842970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174842970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174842970">(Sep 04 2019 at 00:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> is there anything I can help with at the moment? Should I take a look at that branch, and see if I can figure out the root cause of the assertion failure?</p>



<a name="174844102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174844102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hal Gentz <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174844102">(Sep 04 2019 at 01:26)</a>:</h4>
<p>Hello folks! I've been told that you, <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, are the one to ask about anything relating to lazy-normalization, so I'm asking here: I've got a good amount of free time and would love to help get lazy normalization functional with const generics. Alas, opengl knowledge doesn't exactly help with contributing to rustc, or compilers in general, so I'm completely out of my waters and am bassically complete beginner wrt rustc. That stated, are there any problems suitable for first-time contributors that I could work on that would help you get this closer to being up and running?</p>



<a name="174924824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/174924824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#174924824">(Sep 04 2019 at 21:30)</a>:</h4>
<blockquote>
<p>is there anything I can help with at the moment? Should I take a look at that branch, and see if I can figure out the root cause of the assertion failure?</p>
</blockquote>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> yeah, sorry, those comments didn't arrive at an actionable state. Indeed if you wanted to look into the source of that assertion failure, it could be useful. </p>
<p>What i've found is that the error is basically "legit" -- we are being asked to evaluate a predicate like this:</p>
<div class="codehilite"><pre><span></span>Binder(TraitPredicate(&lt;[u8; Const { ty: usize, val: Unevaluated(DefId(0:29231 ~ core[db27]::str[0]::pattern[0]::CharSearcher[0]::utf8_encoded[0]::{{constant}}[0]), [ReLateBound(DebruijnIndex(1), BrAnon(0))]) }] as marker::Sized&gt;))
</pre></div>


<p>this is rather hard to read but the key bit is the <code>ReLateBound(DebruijnIndex(1), BrAnon(0))</code> -- this basically says there is some region with debruijn index 1, but we only have 1 level of binder in scope here, so we would not expect a region with index &gt; 0. Now the question is where this type came from.</p>
<p>I think it has something to do with the <code>core::Searcher</code> trait (which actually is a common source of assertion failures of this kind). I think it's arising when compiling this snippet:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Pattern</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">char</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Searcher</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CharSearcher</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="cp">#[inline]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">into_searcher</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">haystack</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Searcher</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">utf8_encoded</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">];</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">utf8_size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">encode_utf8</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">utf8_encoded</span><span class="p">).</span><span class="n">len</span><span class="p">();</span><span class="w"></span>
</pre></div>


<p>My guess is that somewhere relatively early on we are somehow miscounting the depth or otherwise mishandling the <code>'a</code> that appears in there. I'm not quite sure. I guess maybe trying to minimize down the hunk of libcore that encouters the problem might be a start, i've done that in the past.</p>



<a name="175016023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175016023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175016023">(Sep 05 2019 at 21:22)</a>:</h4>
<p>I'm ending up with a different error message when I try to build your branch:</p>
<div class="codehilite"><pre><span></span>DEBUG 2019-09-05T21:04:30Z: rustc::traits::project: normalize_with_depth(depth=0, value=ImplHeader { impl_def_id: DefId(0:27284 ~ core[21ad]::array[0]::{{impl}}[61]), self_ty: [_; _], trait_ref: Some(&lt;[_; _] as default::Default&gt;), predicates: [Binder(TraitPredicate(&lt;_ as marker::Sized&gt;)), Binder(TraitPredicate(&lt;_ as default::Default&gt;))] })
DEBUG 2019-09-05T21:04:30Z: rustc::traits::codegen: subst_and_normalize_erasing_regions(param_substs=[_], value=usize, param_env=ParamEnv { caller_bounds: [], reveal: All, def_id: None })
DEBUG 2019-09-05T21:04:30Z: rustc::traits::query::normalize_erasing_regions: normalize_erasing_regions::&lt;&amp;rustc::ty::TyS&gt;(value=usize, param_env=ParamEnv { caller_bounds: [], reveal: All, def_id: None })
error: internal compiler error: src/librustc/ich/impls_ty.rs:213: ty::TyKind::hash_stable() - can&#39;t hash a TyVid _#1t.
</pre></div>


<p>I haven't been able to minimize it - however, it looks like an inference variable is still in a constant expression after rustc has expected it to be replaced</p>



<a name="175016046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175016046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175016046">(Sep 05 2019 at 21:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ^</p>
<p>I think it might be caused by the fact that I'm using incremental compilation (<code>./x.py build -i</code>) - that stack trace involves hashing a type when a query is run</p>



<a name="175016684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175016684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175016684">(Sep 05 2019 at 21:31)</a>:</h4>
<p>Minimized: <a href="https://gist.github.com/Aaron1011/8b69db43800e11a76a1c50d93fa91581" target="_blank" title="https://gist.github.com/Aaron1011/8b69db43800e11a76a1c50d93fa91581">https://gist.github.com/Aaron1011/8b69db43800e11a76a1c50d93fa91581</a></p>



<a name="175018416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175018416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175018416">(Sep 05 2019 at 21:53)</a>:</h4>
<p>This seems like a legitimate error - we're trying to run the const_eval query on a type that still has inference variables,, and we don't know how to hash that type for the query key.</p>
<p>How should lazy normalization interact with incremental compilation? I would assume that we would want to skip caching any queries involving inference variables - but we'd probably want some way of marking which queries expect inference variables, to prevent any regressions</p>



<a name="175200545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175200545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175200545">(Sep 08 2019 at 21:31)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>: I made some progress on your lazy normalization branch here: <a href="https://github.com/Aaron1011/rust/tree/lazy-norm-anon-const" target="_blank" title="https://github.com/Aaron1011/rust/tree/lazy-norm-anon-const">https://github.com/Aaron1011/rust/tree/lazy-norm-anon-const</a></p>
<p>I found two main issues, which I (maybe) fixed on that branch:<br>
1. Trait selection needs to have constants evaluated, since this can affect trait selection (e.g. <code>impl MyTrait for MyStruct&lt;{1 + 1}&gt;</code><br>
2. The <code>const_eval</code> query was receiving types with inference variables in them. This is a more general problem, affecting any queries that attempt to do any sort of trait selection on types they receieve (e.g. <code>is_sized_raw</code>). When we canonicalize the predicate we're trying to select, we attempt to resolve any region inference variables found in the predicate. However, when we cross a query boundary, we create a new InferCtxt. This means that we end up trying to resolve inference variables from one InferCtxt in a completely different InferCtxt.<br>
The workaround I came up with was to replace all ReVars with ReErased when running const eval. However, this might be completely wrong - my goal was just to see how far the compiler could get.</p>
<p>After applying those workaround, the compiler was able to build libcore, libstd, and several other crates. However, I wasn't able to fully bootstrap the stage1 compiler, due to a legitimate cycle error. Running const_eval eventually ended up needing to run <code>param_env</code> - since <code>param_env</code> does normalization, it needed to be able to const-eval the same type.</p>
<p>Based on that, I don't think it's going to be possible to get further with 'const only' lazy normalization, - we'll need lazy normalization of associated types as well</p>



<a name="175263313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175263313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175263313">(Sep 09 2019 at 17:24)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> cool! let me read a bit. that cycle error is precisely the one I want to uncover. I <em>suspect</em> though we can solve it the same way we solve normalization for associated types</p>



<a name="175263743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175263743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175263743">(Sep 09 2019 at 17:29)</a>:</h4>
<p>I think the correct solution for inference variables might be 'serialize' part of the inferctxt state, and 'deserialize' it on the other side if the query boundary</p>



<a name="175263910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175263910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175263910">(Sep 09 2019 at 17:30)</a>:</h4>
<p>That is, if we have <code>_#3r: _#2r </code> in the ParamEnv we pass to a query, we want to create new inference variables in the fresh InferCtxt such that <code>_#1r: _#0r</code>.</p>



<a name="175264074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175264074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175264074">(Sep 09 2019 at 17:32)</a>:</h4>
<p>Since those regions constraints could affect trait selection run against the paramenv (e.g <code>impl&lt;'a, 'b: 'a&gt; MyTrait&lt;'a, 'b&gt; for MyType&lt;'a, 'b&gt;</code></p>



<a name="175266469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175266469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175266469">(Sep 09 2019 at 17:58)</a>:</h4>
<blockquote>
<p>I think the correct solution for inference variables might be 'serialize' part of the inferctxt state, and 'deserialize' it on the other side if the query boundary</p>
</blockquote>
<p>this is what canonicalization does</p>



<a name="175266490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175266490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175266490">(Sep 09 2019 at 17:58)</a>:</h4>
<p>have you seen the <a href="https://rust-lang.github.io/rustc-guide/traits/canonical-queries.html" target="_blank" title="https://rust-lang.github.io/rustc-guide/traits/canonical-queries.html">rustc-guide chapter</a> on that, btw?</p>



<a name="175266538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175266538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175266538">(Sep 09 2019 at 17:58)</a>:</h4>
<p>well, it's not exactly what canonicalization does, but that's on purpose</p>



<a name="175267204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175267204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175267204">(Sep 09 2019 at 18:03)</a>:</h4>
<p>It is similar - however, I think canonicicalization replaces <em>all</em> region variables.<br>
For the purposes of the query system, I think we only need to care about ReVar. For example, <code>MyType: MyTrait&lt;'static&gt;</code> is fine</p>



<a name="175267282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175267282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175267282">(Sep 09 2019 at 18:03)</a>:</h4>
<p>I think early bound regions are fine too - e.g. <code>MyType: MyTrait&lt;'a&gt;</code>.<br>
The only problem is ReVar, because it references state that's encoded in the InferCtxt.</p>



<a name="175267435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175267435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175267435">(Sep 09 2019 at 18:05)</a>:</h4>
<p>I'm working under the assumption that in general, queries might want to do things with the ParamEnv other than passing it to a SelectionCtxt.<br>
That is, we want to provide them with as much information as possible.</p>



<a name="175269495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175269495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175269495">(Sep 09 2019 at 18:28)</a>:</h4>
<p>Would it make sense to introduce a weaker kind of canonicalization, which only deals with ReVar? We could change all queries taking <code>ParamEvn</code> to take a <code>WeakCanonicalized&lt;ParamEnv&gt;</code>, and remove the <code>Key</code> impl for <code>ParamEnv</code></p>



<a name="175269585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175269585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175269585">(Sep 09 2019 at 18:29)</a>:</h4>
<p><code>WeakCanonicalized&lt;T&gt;</code> would have one method: <code>instantiate(infcx: &amp;InferCtxt)</code>, which would return a <code>T </code> with freshly created inference variables from the <code>InferCtxt</code></p>



<a name="175272273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175272273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175272273">(Sep 09 2019 at 18:59)</a>:</h4>
<blockquote>
<p>It is similar - however, I think canonicicalization replaces <em>all</em> region variables.<br>
For the purposes of the query system, I think we only need to care about ReVar. For example, <code>MyType: MyTrait&lt;'static&gt;</code> is fine</p>
</blockquote>
<p>It's better to replace all, it creates a more canonical result, and they don't impact the result in any way.</p>



<a name="175272378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175272378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175272378">(Sep 09 2019 at 19:00)</a>:</h4>
<blockquote>
<p>I'm working under the assumption that in general, queries might want to do things with the ParamEnv other than passing it to a SelectionCtxt.<br>
That is, we want to provide them with as much information as possible.</p>
</blockquote>
<p>Well, we'll see, but the current canonicalization system is designed in part to <em>restrict</em> what queries can do -- basically, I want to execute the query once and then be able to re-use the results for all possible lifetimes later</p>



<a name="175272614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175272614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175272614">(Sep 09 2019 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>: Does const-evaluation only use the ParamEnv for trait selection, then? Or does it only use it in ways where the specific lifetimes don't matter?</p>



<a name="175272720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175272720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175272720">(Sep 09 2019 at 19:04)</a>:</h4>
<p>My concern was that some part of const evaluation might actually want to distinguish between <code>MyType: MyTrait&lt;_#0r&gt;</code> and <code>MyType: MyTrait&lt;'static&gt;</code>, but maybe that's never the case.</p>



<a name="175273067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175273067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175273067">(Sep 09 2019 at 19:08)</a>:</h4>
<p>that should never be the case</p>



<a name="175273119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175273119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175273119">(Sep 09 2019 at 19:09)</a>:</h4>
<blockquote>
<p>Does const-evaluation only use the ParamEnv for trait selection, then? Or does it only use it in ways where the specific lifetimes don't matter?</p>
</blockquote>
<p>I think only for trait selection, correct</p>



<a name="175273773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175273773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175273773">(Sep 09 2019 at 19:16)</a>:</h4>
<p>sounds reasonable. Should I take a shot at switching all queries that take a ParamEnv (<code>is_freeze_raw</code>, `const_eval, etc) to take a canonicalized ParamEnv?</p>



<a name="175273909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175273909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175273909">(Sep 09 2019 at 19:18)</a>:</h4>
<p>I think that such a change could actually be landed independently of lazy normalization stuff. I don't think we would ever want region inference variables to move across a query boundary.</p>



<a name="175273977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175273977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175273977">(Sep 09 2019 at 19:19)</a>:</h4>
<blockquote>
<p>sounds reasonable. Should I take a shot at switching all queries that take a ParamEnv (<code>is_freeze_raw</code>, `const_eval, etc) to take a canonicalized ParamEnv?</p>
</blockquote>
<p>sounds great! keep me updated</p>



<a name="175274021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175274021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175274021">(Sep 09 2019 at 19:20)</a>:</h4>
<p>I still haven't had time to dig into your commits btw, I hope to do so before end of day</p>



<a name="175660127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175660127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175660127">(Sep 13 2019 at 20:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> After experimenting locally, I'm not sure that canonicalizing the ParamEnv is the best idea. Since it replaces <em>all</em> regions variables with inference variables, we end up with a lot of region variables in places where we wouldn't otherwise have them.</p>
<p>The end result was the canonicalization was fairly 'infectious' - I had to start modifying a bunch of other places to handle canonicalizaiton and instantiating ParamEnvs. It's still not at the point where I can fully bootstrap the compiler</p>



<a name="175660210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175660210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175660210">(Sep 13 2019 at 20:14)</a>:</h4>
<p>I'm starting to wonder if it might be easier to ban inference variables entirely in queries, and work backwards to see if we can find and eliminate them from where they creep in from lazy normalization (of constants)</p>



<a name="175761122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/175761122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#175761122">(Sep 15 2019 at 18:51)</a>:</h4>
<p>I ran into <a href="https://github.com/rust-lang/rust/issues/64494" target="_blank" title="https://github.com/rust-lang/rust/issues/64494">https://github.com/rust-lang/rust/issues/64494</a> when working on this.</p>



<a name="176227642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176227642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176227642">(Sep 20 2019 at 20:26)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> argh, I thought I wrote you back, but it appears I didn't..? </p>
<p>Anyway, the whole point of canon is to eliminate inference variables from queries, at least in a literal sense. </p>
<p>I'm pretty sure that canonicalizing is the right approach, but maybe you can point me at your branch?</p>



<a name="176228147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176228147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176228147">(Sep 20 2019 at 20:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> After digging further, it turns out that some (maybe all?) of the need to canonicalize was coming from coherence checking. I ended up opening an issue regarding that: <a href="https://github.com/rust-lang/rust/issues/64494" target="_blank" title="https://github.com/rust-lang/rust/issues/64494">https://github.com/rust-lang/rust/issues/64494</a></p>
<p>I think we'll be able to sidestep this entire issue, and simultaneously get the proper coherence behavior, by adopting one of the two approaches I described in that issue.</p>



<a name="176228265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176228265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176228265">(Sep 20 2019 at 20:35)</a>:</h4>
<p>Either forbidding const expression in 'where' clauses from depending on generic parameters, or doing a deliberate overapproximation with respect to coherence.</p>
<p>In either case, there shouldn't be any inference variables to worry about in const eval. Either there are no generic parameters (and therefore nothing to worry about replacing), or we treat the impl as 'potentially always applying' (in which case there is no need to actually do const eval during coherence checking)</p>



<a name="176228291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176228291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176228291">(Sep 20 2019 at 20:35)</a>:</h4>
<p>Oops - I think I replied to the wrong thread</p>



<a name="176228353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176228353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176228353">(Sep 20 2019 at 20:36)</a>:</h4>
<p>no, seems right</p>



<a name="176228390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176228390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176228390">(Sep 20 2019 at 20:37)</a>:</h4>
<p>Still trying to figure out how zulup works ;P</p>



<a name="176229173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/176229173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#176229173">(Sep 20 2019 at 20:48)</a>:</h4>
<p>I think I'll take a shot at implementing the conservative restriction suggested by <span class="user-mention" data-user-id="121053">@varkor</span>, where we forbid arbitrary const expression in <code>where</code> clauses. That will allow us to skip const evaluation in where claues, and instead perform a direct comparison between const parameters when doing coherence checking.</p>
<p>If we ever expand which kinds of const expressions are allowed in 'where' claues, we could just modify the coherence check to take that into account.</p>



<a name="177369570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369570">(Oct 04 2019 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> so I started reading your branch</p>



<a name="177369596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369596">(Oct 04 2019 at 19:04)</a>:</h4>
<p>I am trying to remember</p>



<a name="177369668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369668">(Oct 04 2019 at 19:04)</a>:</h4>
<p>Do we have a canonical example yet of what "goes wrong"</p>



<a name="177369676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369676">(Oct 04 2019 at 19:04)</a>:</h4>
<p>in the absence of lazy norm</p>



<a name="177369705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369705">(Oct 04 2019 at 19:05)</a>:</h4>
<p>I've asked <span class="user-mention" data-user-id="119009">@eddyb</span> and <span class="user-mention" data-user-id="124288">@oli</span> about this before ..</p>



<a name="177369736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177369736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177369736">(Oct 04 2019 at 19:05)</a>:</h4>
<p>/me goes back to do some more experiments</p>



<a name="177376237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376237">(Oct 04 2019 at 20:29)</a>:</h4>
<p>OK so</p>



<a name="177376245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376245">(Oct 04 2019 at 20:29)</a>:</h4>
<p>I returned to my original branch <span class="user-mention" data-user-id="125294">@Aaron Hill</span></p>



<a name="177376255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376255">(Oct 04 2019 at 20:29)</a>:</h4>
<p>fixed a bug in the type folding code for constants</p>



<a name="177376260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376260">(Oct 04 2019 at 20:29)</a>:</h4>
<p>that is what was causing the ICE -- not sure if you told me that already :)</p>



<a name="177376263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376263">(Oct 04 2019 at 20:29)</a>:</h4>
<p>now i'm seeing this</p>



<a name="177376265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376265">(Oct 04 2019 at 20:29)</a>:</h4>
<div class="codehilite"><pre><span></span>error[E0391]: cycle detected when processing `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
    |
note: ...which requires processing `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`...
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
note: ...which requires const-evaluating + checking `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`\
...
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
note: ...which requires const-evaluating + checking `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`\
...
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
note: ...which requires const-evaluating `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`...
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
    = note: ...which again requires processing `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`, com\
pleting the cycle
note: cycle used when const-evaluating `x86_64::sse2::&lt;impl at /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:524:1: 544:2&gt;::{{constant}}#0`
   --&gt; /home/nmatsakis/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.5/src/x86_64/sse2.rs:526:27
    |
526 |     Self: MultiLane&lt;[u32; 4]&gt;,
    |                           ^
</pre></div>



<a name="177376277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177376277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177376277">(Oct 04 2019 at 20:29)</a>:</h4>
<p>which I think is the cycle error I've been looking for</p>



<a name="177379835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177379835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177379835">(Oct 04 2019 at 21:17)</a>:</h4>
<div class="codehilite"><pre><span></span>query stack during panic:
#0 [const_eval_raw] const-evaluating `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#1 [const_eval] const-evaluating + checking `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#3 [param_env] processing `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#4 [typeck_tables_of] processing `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#5 [const_eval_raw] const-evaluating `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#6 [const_eval] const-evaluating + checking `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#7 [const_eval] const-evaluating + checking `&lt;x86_64::sse2::u32x4_sse2&lt;S3, x86_64::YesS4, NI&gt; as types::types::Vec4&lt;u32&gt;&gt;::{{constant}}#0`
#8 [specialization_graph_of] processing `types::types::Vec4`
#9 [coherent_trait] coherence checking all impls of trait `types::types::Vec4`
#10 [analysis] running analysis passes on this crate
end of query stack
</pre></div>



<a name="177380759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177380759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177380759">(Oct 04 2019 at 21:29)</a>:</h4>
<p>OK, I'm catching up now to the cycle you were talking about <span class="user-mention" data-user-id="125294">@Aaron Hill</span> . I'll read that issue then leave some thoughts.</p>



<a name="177566312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/177566312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#177566312">(Oct 07 2019 at 22:19)</a>:</h4>
<p>OK, I've been doing more exploration. <a href="https://hackmd.io/S8cE-e-ORtCqjJzyOU5cLQ" target="_blank" title="https://hackmd.io/S8cE-e-ORtCqjJzyOU5cLQ">Here is a doc with my current thoughts</a></p>



<a name="180404702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180404702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180404702">(Nov 11 2019 at 08:02)</a>:</h4>
<p>Hello, I'm interested in having a look around and experimenting with this. The current branch that I'm working on is here: <a href="https://github.com/skinny121/rust/tree/lazy-norm-anon-const" target="_blank" title="https://github.com/skinny121/rust/tree/lazy-norm-anon-const">https://github.com/skinny121/rust/tree/lazy-norm-anon-const</a>, I started off by building on top of both <span class="user-mention" data-user-id="125294">@Aaron Hill</span> and <span class="user-mention" data-user-id="116009">@nikomatsakis</span> branches and then started to implement the <code>ConstEquate</code> obligations outlined in the above doc. </p>
<p>The current problem I have is demonstrated with the following:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="mi">5</span><span class="p">]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="mi">6</span><span class="p">]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p>When it computs if these two impls overlap, It tries to equate the two constants, but with my current code, it can't due to type variables appearing within the <code>substs</code> of the unevaluated consts. The error message with -Z verbose is:<br>
'conflicting implementations of trait <code>A</code> for type <code>[_#0t; Const { ty: usize, val: Unevaluated(DefId(0:6 ~ main[317d]::{{impl}}[0]::{{constant}}[0]), [_#0t]) }]</code>'.</p>
<p>Should we somehow filter the <code>subsets</code> so that they only contain the substitutions that are actually being used within the const?</p>



<a name="180777864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180777864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180777864">(Nov 14 2019 at 21:37)</a>:</h4>
<p>did anything happen here <span class="user-mention" data-user-id="224180">@Ben Lewis</span>, <span class="user-mention" data-user-id="116009">@nikomatsakis</span>? I'm keen for this to move forward!</p>



<a name="180794448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180794448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180794448">(Nov 15 2019 at 01:29)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> No I haven't done anything more since that comment.</p>



<a name="180906783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180906783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180906783">(Nov 16 2019 at 10:27)</a>:</h4>
<p>Argh, <span class="user-mention" data-user-id="224180">@Ben Lewis</span> sorry for not getting back to you. I've had your comment starred for some time.</p>



<a name="180906786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180906786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180906786">(Nov 16 2019 at 10:27)</a>:</h4>
<p>Well, since Nov 11 :)</p>



<a name="180906840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180906840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180906840">(Nov 16 2019 at 10:28)</a>:</h4>
<p>I think the nswer is that we ned to canonicalize those substs, but let me check out your branch itself. BTW, if you have time to press on this, maybe we should consider setting up a regular meeting time <span class="user-mention" data-user-id="224180">@Ben Lewis</span> ? I'd like to actually answer you in a timely fashion.</p>



<a name="180948427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180948427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180948427">(Nov 17 2019 at 08:20)</a>:</h4>
<p>I do have some time to dedicate to this, though my timezone is UTC +13, which might make it a little difficult.</p>



<a name="180948654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/180948654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#180948654">(Nov 17 2019 at 08:29)</a>:</h4>
<p>BTW as a workaround, I used <code>self.selcx.infcx().freshen(substs)</code> to remove the inference variables which worked but canonicalizing it should better.</p>



<a name="183006256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183006256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183006256">(Dec 09 2019 at 22:19)</a>:</h4>
<p>OK, well, <span class="user-mention" data-user-id="224180">@Ben Lewis</span>, I'm back now and trying to get up to speed. Do you have more updates on that branch? I suppose I will schedule <em>myself</em> some time to review your branch and try to provide you with feedback to start (and/or help to push things along).</p>



<a name="183006337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183006337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183006337">(Dec 09 2019 at 22:20)</a>:</h4>
<p>I'm at UTC-05:00, so that is indeed a formidable time difference. =)</p>



<a name="183037320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183037320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183037320">(Dec 10 2019 at 08:01)</a>:</h4>
<p>Since my last comment, I have managed to get the standard library compiling and most of the tests passing. I did discover that my workaround above isn't sufficient and we do need to turn <code>const_eval</code> queries into canonical queries. For preparation for that, I opened <a href="https://github.com/rust-lang/rust/pull/66877" target="_blank" title="https://github.com/rust-lang/rust/pull/66877">https://github.com/rust-lang/rust/pull/66877</a> to reduce the number of places that invoking the underlying query.</p>
<p>Some other problems are:</p>
<ul>
<li>Constants can't be evaluated when they are printed as it causes cycles. This is the cause of most of the remaining failing tests.</li>
<li><code>let p: &amp;[[u8; 2]] = unsafe {&amp;*(p as *const [[u8; 2]])};</code>Here, the <code>CastCheck</code> doesn't quite work correctly, it passes <code>try_coercion_cast</code> though it shouldn't as it has a <code>ConstEquate</code> obligations which will not be satisfied.</li>
</ul>



<a name="183107305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183107305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183107305">(Dec 10 2019 at 21:59)</a>:</h4>
<p><span class="user-mention" data-user-id="224180">@Ben Lewis</span> great! I didn't get time to look into that today, I'm doing other reviewing now, but I'll try to earmark some time for tomorrow</p>



<a name="183662794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183662794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183662794">(Dec 17 2019 at 16:08)</a>:</h4>
<p><span class="user-mention" data-user-id="224180">@Ben Lewis</span> do you plan to to turn constants into canonical queries (which I definitely agree is a good step) before the other changes on that branch? I'm reviewing the code there but there's a lot of diffs atm so I've not quite figured out if it's doing what I expected or not yet :)</p>



<a name="183915700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183915700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183915700">(Dec 20 2019 at 07:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Yes  that's the plan, I have a branch with it mostly done(<a href="https://github.com/rust-lang/rust/compare/master...skinny121:canonicalize-const-eval?expand=1" target="_blank" title="https://github.com/rust-lang/rust/compare/master...skinny121:canonicalize-const-eval?expand=1">https://github.com/rust-lang/rust/compare/master...skinny121:canonicalize-const-eval?expand=1</a>). I just need to figure out a couple of small issues first before I create a PR for it.</p>



<a name="183926073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/183926073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#183926073">(Dec 20 2019 at 11:00)</a>:</h4>
<p><span class="user-mention" data-user-id="224180">@Ben Lewis</span> great, maybe I'll take a look at that branch first then</p>



<a name="184562367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/184562367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#184562367">(Dec 31 2019 at 19:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Do you think it would be a good idea for me to create a PR with my initial lazy normization work, but hide it behind a <code>-Z lazy-normalization</code> flag?</p>



<a name="184562531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/184562531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#184562531">(Dec 31 2019 at 19:51)</a>:</h4>
<p>That would mean that the work can be broken down into multiple PRs to avoid having one massive PR. Also would allow it to be experimented with by others before we enable it by default.</p>



<a name="184935046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/184935046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#184935046">(Jan 06 2020 at 18:57)</a>:</h4>
<p><span class="user-mention" data-user-id="224180">@Ben Lewis</span> I think you did so, right? seems good. I'm hoping to finish reviewing your first one today.</p>



<a name="184986164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/lazy-normalization%20and%20const%20generics/near/184986164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ben Lewis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/lazy-normalization.20and.20const.20generics.html#184986164">(Jan 07 2020 at 06:37)</a>:</h4>
<p>Yes, I went ahead and implemented it.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>